package cn.b.sky.shop.activiti;

import org.restlet.data.Form;
import org.restlet.data.MediaType;
import org.restlet.representation.InputRepresentation;
import org.restlet.resource.Get;
import org.restlet.resource.ServerResource;

import java.io.InputStream;

public class MyEditorRestResource extends ServerResource {
  @Get
  public InputRepresentation getEditorPage() {
    Form form = getRequest().getResourceRef().getQueryAsForm();
    String language = form.getFirstValue("userLanguage");
    InputStream editorStream = this.getClass().getClassLoader().getResourceAsStream("editor_" + language + ".html");
    InputRepresentation editorResultRepresentation = new InputRepresentation(editorStream);
    editorResultRepresentation.setMediaType(MediaType.APPLICATION_XHTML);
    return editorResultRepresentation;
  }

}
